<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title></title>
		<link rel="stylesheet" href="">
		<link rel="stylesheet" type="text/css" href="./css/api.css" />
		<link rel="stylesheet" type="text/css" href="./css/base.css">
		<link rel="stylesheet" type="text/css" href="./css/news.css">
		<link rel="stylesheet" href="./css/CFNetPP_Base.css">
		<style type="text/css" media="screen">
			.body {
				margin: 0;
				padding: 0;
			}
			#div_newsDetails {
				margin-top: 44px;
				margin-left: 10px;
				margin-right: 10px;
				margin-bottom: 0px;
				/* background: gray; */
			}
			.item_text_title {
				margin-top: 60px;
				text-align: center;
			}
			.max {
				width: 100%;
				height: auto;
			}
			.min {
				width: api .winWidth - 20px;
				height: auto;
			}
			.item_text_bz {
				/*background-color: green;*/
				width: 100%;
				height: 20px;
				text-align: center;
			}
		</style>
	</head>
	<body>
		<div  id="div_newsDetails" hidden="hidden">
			<h4 class="item_text_title font16" id="newsDetailsTitle"><!-- 我是新闻标题 --></h4>
			<span class="item_text_bz" style="color:black;" ><span id="newsDetailsCtime"></span> </span>
			<!-- post返回来的内容主体 -->
			<div id="newsDetailsContent" ></div>
		</div>
		<div class="noSign"   id="noData"  hidden="hidden">
			<img src="./image/icon_nodata.png" width="60%">
			<p class="font16 top_15 base_dark_grey" >
				暂无数据
			</p>
		</div>
		<div class="loadFailure"  id="noNet" hidden="hidden">
			<img src="./image/icon_nonet.png" width="60%">
			<p class="" >
				数据加载失败
			</p>
			<p>
				请检查您的网络
			</p>
			<button type="button" class="mui-btn mui-btn-outlined" onclick="RefreshData()">
				重新加载
			</button>
		</div>
		<div class="base_navigation_bar base_style_color base_navigation_item_bar">
			<a class="base_left_item" href="#" onclick="backClick()"> <img class="base_back_icon" src="./image/icon_jiantou.png" alt=""> </a>
			<span id="newsTitle">新闻题目</span>
			<a class="base_right_item" onclick="onShareClick()"> <!-- 分享 --> <img class="base_item_icon" src="./image/icon_lan.png"  > </a>
		</div>
	</body>
	<script type="text/javascript" src="./script/api.js"></script>
	<script type="text/javascript" src="./script/requestTool.js"></script>
	<script type="text/javascript" src="./script/MD5.js"></script>
	<script type="text/javascript" src="./script/common.js"></script>
	<script type="text/javascript" src="./script/jquery.min.js"></script>
	<script type="text/javascript">
		//分享的信息
		var url = "http://cfnet.org.cn/";
		var title = "长风网";
		var description = "长风网首页新闻中心";
		var thumbUrlQQ = "http://ossimg.cfnet.org.cn/img/20170401/20256-1491034638-81234.png";
		var thumbUrlWV = "../../icon/wxshare.png";
		apiready = function() {
			/*请求数据*/
			get_data();
		}
		//加载失败点击了刷新按钮
		function RefreshData() {
			$('#noNet').hide();
			/*等待加载时的提示框*/
			postprogress();
			//加载最新数据
			get_data();
		}

		/*请求数据*/
		function get_data() {
			/*显示提示框*/
			showProgress();
			/*参数*/
			var params = {
				typeid : api.pageParam.typeid,
				sonid : api.pageParam.sonid,
			};
			cfnetppPOST(url_getNewsDetail, params, true, function(data, status) {
				api.hideProgress();
				if (status == 'success') {
					$('#noNet').hide();
					if (data.code == 200) {
						api.refreshHeaderLoadDone();
						$('#div_newsDetails').show();
						$('#noData').hide();
						var list = data.data;
						// alert(list.body);
						$('#newsDetailsTitle').text(escape2Html(list.title).replace(/&/g, ''));
						$('#newsDetailsCtime').text(getCurrentDate(list.pubdate));
						$('#newsTitle').text(list.title);
						title = escape2Html(list.title);
						var str = list.litpic;
						if (str != undefined & str != null & str != '') {
							if (str.substr(0, 7) == "http://") {
								url = str;
							} else {
								url = "http://" + str;
							}
						}
						/*设置content主体内容根据json的html代码*/
						$('#newsDetailsContent').html(list.body+"<br><br>");
						/*直接设置图片的宽度不超过屏幕的最大宽度*/
						$("#newsDetailsContent  img").width("100%");
						$("#newsDetailsContent  img").height('auto');
						/*传入的是带有img标签的html的json字符串,实现了点击图片放大查看*/
						imageTapToSee('#newsDetailsContent');
					} else {
						$('#noData').show();
						//				api.toast({
						//					msg : '暂无数据',
						//					duration : 2000,
						//					location : 'bottom'
						//				});
					}
				} else {
					$('#noNet').show();
					api.toast({
						msg : '获取数据失败',
						duration : 2000,
						location : 'bottom'
					});
				}
			});
		};
		/*等待加载时的提示框*/
		function postprogress() {
			api.showProgress({
				style : 'default',
				animationType : 'fade',
				title : '正在请求数据...',
				text : '请稍等...',
				modal : true
			});
		}

		function backClick() {
			api.closeWin();
		}

		//分享
		function onShareClick() {
			// alert("要分享的新闻的id是"+newsId);
//			alert(url);
			var dialogBox = api.require('dialogBox');
			dialogBox.actionMenu({
				tapClose : true,
				rect : {
					h : 150
				},
				texts : {
					cancel : '取消'
				},
				items : [{
					text : '微信',
					icon : 'widget://image/icon_weixin.png'
				}, {
					text : 'QQ',
					icon : 'widget://image/icon_qq.png'
				}, {
					text : '朋友圈',
					icon : 'widget://image/icon_pengyouquan.png'
				}, {
					text : 'QQ空间',
					icon : 'widget://image/icon_kongjian.png'
				}],
				styles : {
					bg : '#FFF',
					column : 4,
					itemText : {
						color : '#000',
						size : 12,
						marginT : 8
					},
					itemIcon : {
						size : 60
					},
					cancel : {
						//		            bg:'widget://image/icno_share_buttom.png',
						color : '#000',
						h : 40,
						size : 14
					}
				}
			}, function(ret) {
				var eventType = ret.eventType;
				//判断类型
				var index = ret.index;
				if (eventType == 'cancel') {//关闭
					dialogBox.close({
						dialogName : 'actionMenu'
					});
					return;
				}
				if (index == 1 || index == 3) {
					var qq = api.require('qq');
					qq.installed(function(ret, err) {
						if (ret.status) {
							if (index == 1) {//qq
								qq.shareNews({
									url : url,
									type : 'QFriend',
									title : title,
									description : description,
									imgUrl : thumbUrlQQ
								}, function(ret, err) {
									dialogBox.close({
										dialogName : 'actionMenu'
									});
									if (ret.status) {
										api.toast({
											msg : '分享成功qq'
										});
									} else {
										api.toast({
											msg : '分享失败qq'
										});
									}
								});
							} else if (index == 3) {//qq空间
								qq.shareNews({
									url : url,
									type : 'QZone',
									title : title,
									description : description,
									imgUrl : thumbUrlQQ
								}, function(ret, err) {
									dialogBox.close({
										dialogName : 'dialogBox'
									});
									if (ret.status) {
										api.toast({
											msg : '分享成功qq空间'
										});
									} else {
										api.toast({
											msg : '分享失败qq空间'
										});
									}
								});
							}
							return;
						} else {
							dialogBox.close({
								dialogName : 'actionMenu'
							});
							alert("没有安装QQ");
							// $("#passFailCount").show();
							//  $("#title_text").html('没有安装QQ');
						}
					});
				}
				if (index == 0 || index == 2) {
					var wx = api.require('wx');
					wx.isInstalled(function(ret, err) {
						if (ret.installed) {
							if (index == 0) {//微信
								wx.shareWebpage({
									apiKey : '',
									scene : 'session',
									title : title,
									description : description,
									thumb : thumbUrlWV,
									contentUrl : url
								}, function(ret, err) {
									dialogBox.close({
										dialogName : 'actionMenu'
									});
									if (ret.status) {
										api.toast({
											msg : '分享成功微信好友'
										});
									} else {
										api.toast({
											msg : '分享失败微信好友'
										});
									}
								});
							} else if (index == 2) {//朋友圈
								wx.shareWebpage({
									apiKey : '',
									scene : 'timeline',
									title : title,
									description : description,
									thumb : thumbUrlWV,
									contentUrl : url
								}, function(ret, err) {
									dialogBox.close({
										dialogName : 'actionMenu'
									});
									if (ret.status) {
										api.toast({
											msg : '分享成功朋友圈'
										});
									} else {
										api.toast({
											msg : '分享失败朋友圈'
										});
									}
								});
							}
						} else {
							dialogBox.close({
								dialogName : 'actionMenu'
							});
							alert("没有安装微信");
							//			   $("#passFailCount").show();
							//				       $("#title_text").html('没有安装微信');
						}
					});
				}
			});
		}
	</script>
</html>